package com.jzt.qf.controller;

import com.jzt.qf.beans.UploadBase;
import com.jzt.qf.beans.jztBean.JztYSJLJson;
import com.jzt.qf.beans.uploadJson.JztCKFHjlJson;
import com.jzt.qf.beans.uploadJson.JztJsRecordsJson;
import com.jzt.qf.beans.uploadJson.JztStockTypeJson;
import com.jzt.qf.beans.uploadJson.JztrkysjlJson;
import com.jzt.qf.service.GetService.GetJLService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

/**
 * 　* @description:获取九州通所有记录控制器
 * 　* @author zxy
 * 　* @date 2020-09-10 14:50
 */
@RestController
@RequestMapping("getJztJL")
@Api(tags = "记录控制器controller")
@Slf4j
public class GetJztJLController {
    public static String startDate = "2020-01-01";
    @Autowired
    private GetJLService getJLService;

    @ApiOperation(value = "获取运输记录")
    @GetMapping("/getYSJL")
    public Object getYSJL(String BillCode) {
        JztYSJLJson jztYSJLJson = new JztYSJLJson(BillCode, LocalDate.now().toString());
        UploadBase<JztYSJLJson> uploadBase = new UploadBase("ysjl", "select", jztYSJLJson);
        return getJLService.getYSJL(uploadBase);
    }

    @ApiOperation(value = "获取出库复核")
    @GetMapping("/getCKFH")
    public Object getCKFH(String BillCode, String Goods_No) {
        log.info(Goods_No);
        if (Goods_No == null) {
            Goods_No = "";
        }
        JztCKFHjlJson ckfuJLJson = new JztCKFHjlJson(BillCode, LocalDate.now().toString(), Goods_No);
        UploadBase<JztCKFHjlJson> uploadBase = new UploadBase("xsckjl", "select", ckfuJLJson);
        return getJLService.getCKFH(uploadBase);
    }

    @ApiOperation(value = "获取入库验收")
    @GetMapping("/getRKYS")
    public Object getRKYS(String BillCode, String Goods_No) {
        log.info(Goods_No);
        if (Goods_No == null) {
            Goods_No = "";
        }
        JztrkysjlJson ckfuJLJson = new JztrkysjlJson(BillCode, LocalDate.now().toString(), Goods_No);
        UploadBase<JztCKFHjlJson> uploadBase = new UploadBase("rkysjl", "select", ckfuJLJson);
        return getJLService.getRKYS(uploadBase);
    }

    @ApiOperation(value = "获取拒收记录")
    @GetMapping("/getJsRecords")
    public Object getJsRecords(String billCode) {
        JztJsRecordsJson jsRecordsJson = new JztJsRecordsJson( billCode);
        UploadBase<JztJsRecordsJson> uploadBase = new UploadBase("ypjsjldhcx", "select", jsRecordsJson);
        return getJLService.getJSRecords(uploadBase);
    }

    @ApiOperation(value = "获取库存状态")
    @GetMapping("/getStockType")
    public Object getStockType(String Goods_No) {
        log.info(Goods_No);
        if (Goods_No == null) {
            Goods_No = "";
        }
        JztStockTypeJson stockTypeJson = new JztStockTypeJson("", LocalDate.now().toString(), LocalDate.now().toString(), Goods_No);
        stockTypeJson.setStart_Date(LocalDate.now().toString());
        UploadBase<JztCKFHjlJson> uploadBase = new UploadBase("kcztbh", "select", stockTypeJson);
        return getJLService.getStockType(uploadBase);
    }
}
